package com.xcj.cloud.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/admin")
public class AdminController {

    //管理员登录
    @RequestMapping("/admin_login")
    public String adminLogin(Model model, HttpSession session,
                             @RequestParam String adminName, @RequestParam String aPassword) {
        String msg;
        String url;
/*        String adminName = admin.getAdminName();
        String aPassword = admin.getAPassword();*/
        //判断用户名为空
        /*if ("".equals(adminName) || "".equals(aPassword)) {
            msg = "用户名或密码不能为空！";
            url = "admin/login_";
            model.addAttribute("msg", msg);
            model.addAttribute("url", url);
            return "user/error";
        }
        //查询管理员是否存在
        if (adminService.findAdmin(admin) == null) {
            msg = "用户名或密码错误！";
            url = "admin/login_";
            model.addAttribute("msg", msg);
            model.addAttribute("url", url);
            return "user/error";
        }*/
        //session.setAttribute("adminName", admin.getAdminName());
        session.setAttribute("adminName", adminName);
        return "admin/index";
    }
}
